package cn.wolfcode.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult<T> {

    private Integer code;
    private T data;
    private String message;

    public static <T> JsonResult success(T data){
        JsonResult<T> result = new JsonResult<>();
        result.setCode(200);
        result.setMessage("成功");
        result.setData(data);
        return result;
    }

    public static <T> JsonResult error(String message){
        JsonResult<T> result = new JsonResult<>();
        result.setCode(500);
        result.setMessage(message);
        return result;
    }

}
